package com.wuseguang.springcloud.controller;

import com.wuseguang.springcloud.Filter.RequestParameterWrapper;
import com.wuseguang.springcloud.service.AreaPlatformService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 区级平台账号 前端控制器
 * </p>
 *
 * @author
 * @since 2020-08-12
 */
@RestController
@RequestMapping("/admin")
public class AreaPlatformTwoController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private AreaPlatformService areaPlatformServiceImpl;

    /**
     *查询区级的总体情况
     * @param request
     * @return
     */
    @RequestMapping("/findAreaPopulation")
    public Result findAreaPopulation(RequestParameterWrapper request){
        logger.info("查询区级的总体情况");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findAreaPopulation(Integer.valueOf(areaPlatformId));
    }

    /**
     * 查询区级的使用记录
     * @param request
     * @return
     */
    @RequestMapping("/findAreaUsageRecord")
    public Result findAreaUsageRecord(RequestParameterWrapper request){
        logger.info("查询区级的使用记录");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findAreaUsageRecord(Integer.valueOf(areaPlatformId));
    }

    /**
     * 查询区级的总绑定率
     * @param request
     * @return
     */
    @RequestMapping("/findAreaBinding")
    public Result findAreaBinding(RequestParameterWrapper request){
        logger.info("查询区级的总绑定率");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findAreaBinding(Integer.valueOf(areaPlatformId));
    }

    /**
     * 查询区里面的所有学校
     * @param request
     * @return
     */
    @RequestMapping("/findAreaSchool")
    public Result findAreaSchool(RequestParameterWrapper request){
        logger.info("查询区里面的所有学校");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findAreaSchool(Integer.valueOf(areaPlatformId));
    }

    /**
     * 查询区级里面的各校绑定率
     * @param request
     * @return
     */
    @RequestMapping("/findAreaSchoolsBinding")
    public Result findAreaSchoolsBinding(RequestParameterWrapper request){
        logger.info("查询区级里面的各校绑定率");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findAreaSchoolsBinding(Integer.valueOf(areaPlatformId));
    }

    /**
     * 查询区级里30天的各校活跃排名
     * @param request
     * @return
     */
    @RequestMapping("/findArea30DaysActive")
    public Result findArea30DaysActive(RequestParameterWrapper request){
        logger.info("查询区级里30天的各校活跃排名");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findArea30DaysActive(Integer.valueOf(areaPlatformId));
    }

    /**
     * 查询区级某个学校30天的使用数据
     * @param request
     * @param schoolId
     * @return
     */
    @RequestMapping("/findArea30DaysUseData")
    public Result findArea30DaysUseData(RequestParameterWrapper request,@RequestParam(value = "schoolId") Integer schoolId){
        logger.info("查询区级某个学校30天的使用数据");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findArea30DaysUseData(Integer.valueOf(areaPlatformId),schoolId);
    }

    /**
     * 查询区级累计数据总量
     * @param request
     * @return
     */
    @RequestMapping("/findCumulativeData")
    public Result findCumulativeData(RequestParameterWrapper request){
        logger.info("查询区级累计数据总量-通知，图片，视频，文件，链接，评价，考勤");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findCumulativeData(Integer.valueOf(areaPlatformId));
    }


    /**
     * 全区学生在离校情况
     * @param request
     * @return
     */
    @RequestMapping("/findAreaLeaveAndEnter")
    public Result findAreaLeaveAndEnter(RequestParameterWrapper request){
        logger.info("全区学生在离校情况");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findAreaLeaveAndEnter(Integer.valueOf(areaPlatformId));
    }


    /**
     * 全区学校活动数量
     * @param request
     * @return
     */
    @RequestMapping("/findAreaActivityNumber")
    public Result findAreaActivityNumber(RequestParameterWrapper request){
        logger.info("全区学校活动数量");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findAreaActivityNumber(Integer.valueOf(areaPlatformId));
    }


    /**
     * 全区30天体温检测次数
     * @param request
     * @return
     */
    @RequestMapping("/findArea30DayTemperature")
    public Result findArea30DayTemperature(RequestParameterWrapper request){
        logger.info("全区30天体温检测次数");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findArea30DayTemperature(Integer.valueOf(areaPlatformId));
    }


    /**
     * 全区数据总量排行（包含：通知，图片，视频，文件，链接，评价，考勤。）
     * @param request
     * @return
     */
    @RequestMapping("/findAreaDateTotalRanking")
    public Result findAreaDateTotalRanking(RequestParameterWrapper request){
        logger.info("全区数据总量排行");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findAreaDateTotalRanking(Integer.valueOf(areaPlatformId));
    }

    /**
     * 查询学校用户数量-(教师，学生)
     * @param request
     * @param schoolId 学校id
     * @return
     */
    @RequestMapping("/findSchoolUser")
    public Result findSchoolUser(RequestParameterWrapper request,@RequestParam(value = "schoolId") Integer schoolId){
        logger.info("查询学校用户数量-(教师，学生)");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findSchoolUser(Integer.valueOf(areaPlatformId),schoolId);
    }

    /**
     * 查询学校人脸注册率
     * @param request
     * @param schoolId 学校id
     * @return
     */
    @RequestMapping("/findSchoolFaceRegistration")
    public Result findSchoolFaceRegistration(RequestParameterWrapper request,@RequestParam(value = "schoolId") Integer schoolId){
        logger.info("查询学校人脸注册率");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findSchoolFaceRegistration(Integer.valueOf(areaPlatformId),schoolId);
    }

    /**
     * 查询学校在离校数据
     * @param request
     * @param schoolId 学校id
     * @return
     */
    @RequestMapping("/findLeavingSchool")
    public Result findLeavingSchool(RequestParameterWrapper request,@RequestParam(value = "schoolId") Integer schoolId){
        logger.info("查询学校在离校数据");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findLeavingSchool(Integer.valueOf(areaPlatformId),schoolId);
    }


    /**
     * 查询家长留言
     * @param request
     * @param schoolId 学校id
     * @return
     */
    @RequestMapping("/findParentsMessage")
    public Result findParentsMessage(RequestParameterWrapper request,@RequestParam(value = "schoolId") Integer schoolId){
        logger.info("查询家长留言");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findParentsMessage(Integer.valueOf(areaPlatformId),schoolId);
    }


    /**
     * 查询学校每月数据沉淀
     * @param request
     * @param schoolId 学校id
     * @return
     */
    @RequestMapping("/findDataPrecipitation")
    public Result findDataPrecipitation(RequestParameterWrapper request,@RequestParam(value = "schoolId") Integer schoolId){
        logger.info("查询学校每月数据沉淀");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findDataPrecipitation(Integer.valueOf(areaPlatformId),schoolId);
    }

    /**
     * 查询学校设备的在线情况
     * @param request
     * @param schoolId 学校id
     * @return
     */
    @RequestMapping("/findShoolbancard")
    public Result findShoolbancard(RequestParameterWrapper request,@RequestParam(value = "schoolId") Integer schoolId){
        logger.info("查询学校设备的在线情况");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findShoolbancard(Integer.valueOf(areaPlatformId),schoolId);
    }

    /**
     *  每月评价总量
     * @param request
     * @param schoolId 学校id
     * @return
     */
    @RequestMapping("/findTotalMonthlyEvaluation")
    public Result findTotalMonthlyEvaluation(RequestParameterWrapper request,@RequestParam(value = "schoolId") Integer schoolId){
        logger.info("每月评价总量");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findTotalMonthlyEvaluation(Integer.valueOf(areaPlatformId),schoolId);
    }

    /**
     * 查询班级学生考勤排名
     * @param request
     * @param schoolId 学校id
     * @param type 0 按比例升序，1按比例降序
     * @return
     */
    @RequestMapping("/findAttendanceRanking")
    public Result findAttendanceRanking(RequestParameterWrapper request,
                                        @RequestParam(value = "schoolId") Integer schoolId,
                                        @RequestParam(value = "type",defaultValue = "0",required = false)Integer type){
        logger.info("查询班级学生考勤排名");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findAttendanceRanking(Integer.valueOf(areaPlatformId),schoolId,type);
    }

    /**
     * 查询学校年级
     * @param request
     * @param schoolId
     * @return
     */
    @RequestMapping("/findSchoolGrade")
    public Result findSchoolGrade(RequestParameterWrapper request,
                                  @RequestParam(value = "schoolId") Integer schoolId){
        logger.info("查询学校年级");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findSchoolGrade(Integer.valueOf(areaPlatformId),schoolId);
    }


    /**
     * 查询学校德育排名-按年级
     * @param request
     * @param schoolId 学校id
     * @param gradeId 年级
     * @return
     */
    @RequestMapping("/findGradeRankingLastWeek")
    public Result findGradeRankingLastWeek(RequestParameterWrapper request,
                                           @RequestParam(value = "schoolId") Integer schoolId,
                                           @RequestParam(value = "gradeId") Integer gradeId){
        logger.info("查询学校德育排名-按年级");
        String areaPlatformId = request.getParam("areaPlatformId");
        return areaPlatformServiceImpl.findGradeRankingLastWeek(Integer.valueOf(areaPlatformId),schoolId,gradeId);
    }

}
